﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Weazel.Math;

#endregion

namespace Weazel.Math.Test
{
  [TestClass]
  public class TestMod
  {
    [TestMethod]
    public void TestMod_InvalidArgument()
    {
      Integer a = new Integer(16, 50, false);
      Integer b = new Integer(8, 0, false);

      try
      {
        Integer r = a % b;
      }
      catch (DivideByZeroException)
      {
        return;
      }

      Assert.Fail();
    }

    [TestMethod]
    public void TestMod_1()
    {
      Integer a = new Integer(16, 50, false);
      Integer b = new Integer(8, 5, false);

      Assert.IsTrue((a % b).IsZero());
    }

    [TestMethod]
    public void TestMod_2()
    {
      Integer a = new Integer(16, 50, false);
      Integer b = new Integer(8, 4, false);

      Assert.AreEqual("2", (a % b).ToDecimalString());
    }

    [TestMethod]
    public void TestMod_3()
    {
      Integer a = new Integer(64, 12345678910111213, false);
      Integer b = new Integer(8, 25, false);

      Assert.AreEqual("13", (a % b).ToDecimalString());
    }

    [TestMethod]
    public void TestMod_4()
    {
      Integer a = new Integer(64, "1234567891011121314", false);    
      Integer b = new Integer(64,  12345678910111213, false);

      Assert.AreEqual("14", (a % b).ToDecimalString());
    }

    [TestMethod]
    public void TestMod_5()
    {
      Integer a = new Integer(8, -57, true);
      Integer b = new Integer(8, 11, false);

      Assert.AreEqual("9", (a % b).ToDecimalString());
    }
  }
}
